package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/17 11:03
 * @description
 */
public class Code80 {
    public static void main(String[] args) {
        new Code80().removeDuplicates(new int[] {1, 1, 1, 2, 2, 3});
    }

    public int removeDuplicates(int[] nums) {
        if (nums.length == 0) {
            return 0;
        }
        int index = 0;
        int count = 1;
        int num = nums[0];
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] == num) {
                if (count < 2) {
                    index++;
                    count++;
                }
            } else {
                index++;
                count = 1;
                num = nums[i];
            }
            nums[index] = nums[i];
        }
        return index + 1;
    }
}
